package com.todo.content.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.content.application.frontend.service.ContentRelationAggService;
import com.todo.content.iface.frontend.ContentRelationFrontendIface;
import com.todo.content.iface.frontend.request.QueryContentByClassifyParam;
import com.todo.content.iface.frontend.request.QueryContentByTopicParam;
import com.todo.content.iface.frontend.response.ContentBaseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/17 14:06
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/content")
@Tag(name = "内容关联前台接口", description = "内容关联前台接口")
public class ContentRelationFrontendController implements ContentRelationFrontendIface {

    @Resource
    private ContentRelationAggService contentRelationAggService;


    @Override
    @Operation(summary = "根据话题查询内容列表")
    @PostMapping("/queryContentByTopic")
    public BizPageResponse<ContentBaseVO> queryContentByTopic(@RequestBody QueryContentByTopicParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return contentRelationAggService.queryContentByTopic(param);
    }

    @Override
    @Operation(summary = "根据分类查询内容列表")
    @PostMapping("/queryContentByClassify")
    public BizPageResponse<ContentBaseVO> queryContentByClassify(@RequestBody QueryContentByClassifyParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return contentRelationAggService.queryContentByClassify(param);
    }
}
